1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"949">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #000000}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #000000; min-height: 12.0px}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #782c1a; min-height: 14.0px}
19 span
.s1
{color: #001fee}
20 span
.s2
{color: #000000}
21 span
.s3
{color: #0000bf}
22 span
.s4
{color: #bf0000}
23 span
.s5
{color: #606060}
24 span
.s6
{color: #007300}
25 span
.s7
{font: 9.0px Monaco
; color: #782c1a}
26 span
.Apple-tab-span
{white-space:pre
}
30 <p class=
"p1"><b>DiskOut
</b></p>
31 <p class=
"p2"><br></p>
32 <p class=
"p3"><b>DiskOut.ar(bufnum, channelsArray)
</b></p>
33 <p class=
"p4"><br></p>
34 <p class=
"p3">Record to a soundfile to disk. Uses a
<a href=
"../../ServerArchitecture/Buffer.html"><span class=
"s1">Buffer
</span></a>.
</p>
35 <p class=
"p3"><b>bufnum
</b> - the number of the buffer to write to (prepared with /b-write or Buffer.write)
<span class=
"Apple-converted-space"> </span></p>
36 <p class=
"p3"><b>channelsArray
</b> - the Array of channels to write to the file.
</p>
37 <p class=
"p2"><br></p>
38 <p class=
"p3">The output of DiskOut is the number of frames written to disk.
</p>
39 <p class=
"p2"><br></p>
40 <p class=
"p3">Note that the number of channels in the buffer and the channelsArray must be the same, otherwise DiskOut will fail silently (and not write anything to your file).
</p>
41 <p class=
"p2"><br></p>
43 <p class=
"p5"><span class=
"s2">s.boot;
</span>// start the server
</p>
45 <p class=
"p5">// something to record
</p>
46 <p class=
"p7"><span class=
"s3">SynthDef
</span><span class=
"s2">(
</span>"bubbles"<span class=
"s2">, {
</span></p>
47 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">var
</span> f, zout;
</p>
48 <p class=
"p6"><span class=
"Apple-tab-span"> </span>f =
<span class=
"s3">LFSaw
</span>.kr(
0.4,
0,
24,
<span class=
"s3">LFSaw
</span>.kr([
8,
7.23],
0,
3,
80)).midicps;
<span class=
"s4">// glissando function
</span></p>
49 <p class=
"p6"><span class=
"Apple-tab-span"> </span>zout =
<span class=
"s3">CombN
</span>.ar(
<span class=
"s3">SinOsc
</span>.ar(f,
0,
0.04),
0.2,
0.2,
4);
<span class=
"s4">// echoing sine wave
</span></p>
50 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">Out
</span>.ar(
0, zout);
</p>
51 <p class=
"p6">}).send(s);
</p>
52 <p class=
"p8"><br></p>
53 <p class=
"p5">// this will record to the disk
</p>
54 <p class=
"p7"><span class=
"s3">SynthDef
</span><span class=
"s2">(
</span>"help-Diskout"<span class=
"s2">, {
</span><span class=
"s3">arg
</span><span class=
"s2"> bufnum;
</span></p>
55 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">DiskOut
</span>.ar(bufnum,
<span class=
"s3">In
</span>.ar(
0,
2));
</p>
56 <p class=
"p6">}).send(s);
</p>
57 <p class=
"p8"><br></p>
58 <p class=
"p5">// this will play it back
</p>
59 <p class=
"p7"><span class=
"s3">SynthDef
</span><span class=
"s2">(
</span>"help-Diskin-2chan"<span class=
"s2">, {
</span><span class=
"s3">arg
</span><span class=
"s2"> bufnum =
0;
</span></p>
60 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">Out
</span>.ar(
0,
<span class=
"s3">DiskIn
</span>.ar(
2, bufnum));
</p>
61 <p class=
"p6">}).send(s);
</p>
63 <p class=
"p2"><br></p>
64 <p class=
"p3"><b>Object Style:
</b></p>
65 <p class=
"p8"><br></p>
66 <p class=
"p5">// start something to record
</p>
67 <p class=
"p6">x =
<span class=
"s3">Synth
</span>.new(
<span class=
"s5">"bubbles"</span>);
</p>
68 <p class=
"p8"><br></p>
69 <p class=
"p5">// allocate a disk i/o buffer
</p>
70 <p class=
"p6">b=
<span class=
"s3">Buffer
</span>.alloc(s,
65536,
2);
</p>
71 <p class=
"p8"><br></p>
72 <p class=
"p5">// create an output file for this buffer, leave it open
</p>
73 <p class=
"p6">b.write(
<span class=
"s5">"~/diskouttest.aiff"</span>.standardizePath,
<span class=
"s5">"aiff"</span>,
<span class=
"s5">"int16"</span>,
0,
0,
<span class=
"s3">true
</span>);
</p>
74 <p class=
"p5">// create the diskout node; making sure it comes after the source
</p>
75 <p class=
"p7"><span class=
"s2">d =
</span><span class=
"s3">Synth
</span><span class=
"s2">.tail(
</span><span class=
"s3">nil
</span><span class=
"s2">,
</span>"help-Diskout"<span class=
"s2">, [
</span>"bufnum"<span class=
"s2">, b]);
</span></p>
76 <p class=
"p5">// stop recording
</p>
77 <p class=
"p6">d.free;
</p>
78 <p class=
"p5">// stop the bubbles
</p>
79 <p class=
"p6">x.free;
</p>
80 <p class=
"p5">// close the buffer and the soundfile
</p>
81 <p class=
"p6">b.close;
</p>
82 <p class=
"p5">// free the buffer
</p>
83 <p class=
"p6">b.free;
</p>
84 <p class=
"p2"><br></p>
85 <p class=
"p5">// play it back
</p>
87 <p class=
"p7"><span class=
"s2">x =
</span><span class=
"s3">Synth
</span><span class=
"s2">.basicNew(
</span>"help-Diskin-2chan"<span class=
"s2">);
</span></p>
88 <p class=
"p6">m = {
<span class=
"s3">arg
</span> buf; x.addToHeadMsg(
<span class=
"s3">nil
</span>, [
<span class=
"s6">\bufnum
</span>,buf])};
</p>
89 <p class=
"p8"><br></p>
90 <p class=
"p6">b =
<span class=
"s3">Buffer
</span>.cueSoundFile(s,
<span class=
"s5">"~/diskouttest.aiff"</span>.standardizePath,
0,
2, completionMessage: m);
</p>
92 <p class=
"p6">x.free; b.close; b.free;
<span class=
"s4">// cleanup
</span></p>
93 <p class=
"p2"><br></p>
94 <p class=
"p3"><b>Messaging Style
</b><span class=
"s7">:
</span></p>
95 <p class=
"p8"><br></p>
96 <p class=
"p5">// The same thing done in Messaging Style (less overhead but without the convienence of objects)
</p>
97 <p class=
"p5">// start something to record
</p>
98 <p class=
"p6">s.sendMsg(
<span class=
"s5">"/s_new"</span>,
<span class=
"s5">"bubbles"</span>,
2003,
1,
1);
</p>
99 <p class=
"p8"><br></p>
100 <p class=
"p5">// allocate a disk i/o buffer
</p>
101 <p class=
"p6">s.sendMsg(
<span class=
"s5">"/b_alloc"</span>,
0,
65536,
2);
<span class=
"s4">// Buffer number is
0</span></p>
102 <p class=
"p8"><br></p>
103 <p class=
"p5">// create an output file for this buffer, leave it open
</p>
104 <p class=
"p6">s.sendMsg(
<span class=
"s5">"/b_write"</span>,
0,
<span class=
"s5">"~/diskouttest.aiff"</span>.standardizePath,
<span class=
"s5">"aiff"</span>,
<span class=
"s5">"int16"</span>,
0,
0,
1);
</p>
105 <p class=
"p8"><br></p>
106 <p class=
"p5">// create the diskout node
</p>
107 <p class=
"p6">s.sendMsg(
<span class=
"s5">"/s_new"</span>,
<span class=
"s5">"help-Diskout"</span>,
2004,
3,
2003,
<span class=
"s5">"bufnum"</span>,
0);
</p>
108 <p class=
"p8"><br></p>
109 <p class=
"p6">s.sendMsg(
<span class=
"s5">"/n_free"</span>,
2004);
<span class=
"s4">// stop recording
</span></p>
110 <p class=
"p6">s.sendMsg(
<span class=
"s5">"/n_free"</span>,
2003);
<span class=
"s4">// stop the bubbles
</span></p>
111 <p class=
"p8"><br></p>
112 <p class=
"p5"><span class=
"s2">s.sendMsg(
</span><span class=
"s5">"/b_close"</span><span class=
"s2">,
0);
</span>// close the file.
</p>
113 <p class=
"p6">s.sendMsg(
<span class=
"s5">"/b_free"</span>,
0);
</p>
114 <p class=
"p2"><br></p>
115 <p class=
"p4"><br></p>
116 <p class=
"p3">See
<a href=
"RecordBuf.html"><span class=
"s1">RecordBuf
</span></a> for recording into a buffer in memory.
</p>
117 <p class=
"p9"><br></p>
118 <p class=
"p4"><br></p>
119 <p class=
"p4"><br></p>
120 <p class=
"p4"><br></p>
121 <p class=
"p4"><br></p>